<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../../vue.js"></script>
</head>

<body>

  <div id="app">
    {{username}}
    <compa :username="username"></compa>

  </div>


  <script>

    const compb = {
      props: ['username'],
      template: '<h2>compb-{{username}}</h2>',
      beforeCreate() {
        console.log("grandson beforeCreate")
      },
      created() {
        console.log("grandson Created")
      },
      mounted() {
        console.log('grandson mounted')
      },
      beforeUpdate() {
        console.log('grandson beforeUpdate')
      },
      updated() {
        console.log('grandson updated')
      }
    }


    const compa = {
      props: ['username'],
      template: `
      <div>
        <h1>
          compa-{{username}}
        </h1>
        <compb :username="username"></compb>
      </div>
      `,
      components: {
        compb
      },
      beforeCreate() {
        console.log("child beforeCreate")
      },
      created() {
        console.log("child Created")
      },
      mounted() {
        console.log('child mounted')
      },
      beforeUpdate() {
        console.log('child beforeUpdate')
      },
      updated() {
        console.log('child updated')
      }
    }


    var vm = new Vue({
      el: "#app",
      data: {
        username: 'hanye'
      },
      components: {
        compa
      },
      beforeCreate() {
        console.log("root beforeCreate")
      },
      created() {
        console.log("root Created")
      },
      mounted() {
        console.log('root mounted')
      },
      beforeUpdate() {
        console.log('root beforeUpdate')
      },
      updated() {
        console.log('root updated')
      }

    })

  </script>

</body>

</html>